﻿using System;
//
using PerceptiveMCAPI;
//
namespace PerceptiveMCAPI_Test
{
   public partial class get_listMembers : System.Web.UI.UserControl
   {
      public ApiMethod method { get; set; }
      public string listId
      {
         get { return tbListId.Text.Trim(); }
         set { tbListId.Text = value; }
      }

      public EnumValues.listMembers_status member_status
      {
         get { return ApiHelper.GetEnumFromString<EnumValues.listMembers_status>( ddlMbrStatus.SelectedItem.Text ); }
         set { ddlMbrStatus.SelectedValue = Convert.ToInt32( value ).ToString(); }
      }
      public DateTime since
      {
         get
         {
            DateTime dt; DateTime.TryParse( tbSinceDate.Text.Trim(), out dt );
            return dt;
         }
         set
         {
            if ( value == DateTime.MinValue )
               tbSinceDate.Text = "";
            else
               tbSinceDate.Text = value.ToString();
         }
      }

      public int start
      {
         get { return Convert.ToInt32( tbStart.Text.Trim() ); }
         set { tbStart.Text = value.ToString(); }
      }
      public int limit
      {
         get { return Convert.ToInt32( tbLimit.Text.Trim() ); }
         set { tbLimit.Text = value.ToString(); }
      }

      public string email_address
      {
         get { return tbEmail.Text.Trim(); }
         set { tbEmail.Text = value; }
      }

      // ----------------------------------------------
      public bool Setup()
      {
         this.Visible = true;
         lblSection.Text = method.section;
         lblMethod.Text = method.name;
         tbListId.Focus();
         //
         if ( method.name == "listMembers" )
         {
            divListMembers.Visible = true;
            divListMemberInfo.Visible = false;
            //
            member_status = MCAPISettings.default_listMembers_status;
            start = MCAPISettings.default_start;
            limit = MCAPISettings.default_limit_listMembers;
            ddlMbrStatus.DataSource = EnumValues.listMemberStatusValues();
            ddlMbrStatus.DataBind();
         }
         else
         {
            divListMembers.Visible = false;
            divListMemberInfo.Visible = true;

         }
         return true;
      }

   }
}